package com.itheima.ssm.controller;
import com.itheima.ssm.bean.Account;
import com.itheima.ssm.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/account")
public class CountrollerAccount {

    @Autowired
    private AccountService accountService;
    @RequestMapping("/find")
    public String findAll(Model model){

        System.out.println("表现层：查询所有账户...");
        List<Account> list = accountService.findAll();
        model.addAttribute("list",list);
        return "success";
    }

@RequestMapping("/save")
    public String save(Account account){
        System.out.println("表现层：保存账户...");
        accountService.saveAccount(account);
        return "redirect:/account/find";
    }
}
